﻿
function validate(Email) {

    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;


    if (reg.test(Email) == false) {

        return false;
    }
    else {
        return true;
    }
}
function toggle(div_id) {
    var el = document.getElementById(div_id);
    if (el.style.display == 'none') {
       el.style.display = 'block';
       //  $("#" + div_id).fadeIn("slow");
         
    }
    else {
        el.style.display = 'none';
        // $("#" + div_id).fadeOut("slow");
    }
}
function blanket_size(popUpDivVar) {
    if (typeof window.innerWidth != 'undefined') {
        viewportheight = window.innerHeight;
    } else {
        viewportheight = document.documentElement.clientHeight;
    }
    if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
        blanket_height = viewportheight;
    } else {
        if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
            blanket_height = document.body.parentNode.clientHeight;
        } else {
            blanket_height = document.body.parentNode.scrollHeight;
        }
    }
    var blanket = document.getElementById('blanket');
    blanket.style.height = blanket_height + 'px';
    var popUpDiv = document.getElementById(popUpDivVar);
    popUpDiv_height = blanket_height / 2 - 150; //150 is half popup's height
    popUpDiv.style.top = popUpDiv_height + 'px';
}

function window_pos(popUpDivVar) {
    if (typeof window.innerWidth != 'undefined') {
        viewportwidth = window.innerHeight;
    } else {
        viewportwidth = document.documentElement.clientHeight;
    }
    if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
        window_width = viewportwidth;
    } else {
        if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
            window_width = document.body.parentNode.clientWidth;
        } else {
            window_width = document.body.parentNode.scrollWidth;
        }
    }
    var popUpDiv = document.getElementById(popUpDivVar);
    window_width = window_width / 2 - 250; //150 is half popup's width
    popUpDiv.style.left = window_width + 'px';

}
function popup(windowname,BlanketDiv,RestaurantId) {


    var blanket = document.getElementById(BlanketDiv);
    var browserName = GetBrowserName();

    if (browserName == "Microsoft Internet Explorer") {
     // blanket.style.height = document.documentElement.scrollHeight;
       blanket.style.height = document.documentElement.scrollHeight+100;
      //  blanket.style.width = document.documentElement.scrollWidth;
        // alert("ie" + document.body.offsetHeight);

    }
    else if (browserName == "Firefox") {
        //alert(browserName);
        blanket.style.height = (document.documentElement.scrollHeight) + 'px';
        //blanket.style.width = (document.documentElement.scrollWidth) + 'px';

    }
    else {
       // alert(browserName);
        blanket.style.height = (document.body.scrollHeight) + 'px';
       // blanket.style.width = (document.body.scrollWidth) + 'px';
    }
    //  SetPopupSize(windowname);

    toggle(windowname);
    toggle(BlanketDiv);


    if (windowname == "popUpDiv") {

        if (document.getElementById("hdidUser").value != null) {
            document.getElementById("hdidUser").value = UserId;
        }
    }

    if (windowname == "popUpDiv1") {
        if (document.getElementById("idAmc").value != null) {
            document.getElementById("idAmc").value = UserId;
            alert(UserId);
        }
      
    }
 //      UpdateCounterForAd(idadv);
//    }

}

function GetBrowserName() {
    var nVer = navigator.appVersion;
    var nAgt = navigator.userAgent;
    var browserName = navigator.appName;
    var fullVersion = '' + parseFloat(navigator.appVersion);
    var majorVersion = parseInt(navigator.appVersion, 10);
    var nameOffset, verOffset, ix;

    // In Opera, the true version is after "Opera" or after "Version"
    if ((verOffset = nAgt.indexOf("Opera")) != -1) {
        browserName = "Opera";
        fullVersion = nAgt.substring(verOffset + 6);
        if ((verOffset = nAgt.indexOf("Version")) != -1)
            fullVersion = nAgt.substring(verOffset + 8);
    }
    // In MSIE, the true version is after "MSIE" in userAgent
    else if ((verOffset = nAgt.indexOf("MSIE")) != -1) {
        browserName = "Microsoft Internet Explorer";
        fullVersion = nAgt.substring(verOffset + 5);
    }
    // In Chrome, the true version is after "Chrome" 
    else if ((verOffset = nAgt.indexOf("Chrome")) != -1) {
        browserName = "Chrome";
        fullVersion = nAgt.substring(verOffset + 7);
    }
    // In Safari, the true version is after "Safari" or after "Version" 
    else if ((verOffset = nAgt.indexOf("Safari")) != -1) {
        browserName = "Safari";
        fullVersion = nAgt.substring(verOffset + 7);
        if ((verOffset = nAgt.indexOf("Version")) != -1)
            fullVersion = nAgt.substring(verOffset + 8);
    }
    // In Firefox, the true version is after "Firefox" 
    else if ((verOffset = nAgt.indexOf("Firefox")) != -1) {
        browserName = "Firefox";
        fullVersion = nAgt.substring(verOffset + 8);
    }
    // In most other browsers, "name/version" is at the end of userAgent 
    else if ((nameOffset = nAgt.lastIndexOf(' ') + 1) < (verOffset = nAgt.lastIndexOf('/'))) {
        browserName = nAgt.substring(nameOffset, verOffset);
        fullVersion = nAgt.substring(verOffset + 1);
        if (browserName.toLowerCase() == browserName.toUpperCase()) {
            browserName = navigator.appName;
        }
    }
    return browserName;
}
 
 

 
 

  
 